<?php

require_once 'phpmoko/ui/Form/FormBase.php';

class TextBox extends FormBase
{
	private $size = null;
	private $maxLength = null;
	private $value = null;

	function __construct()
	{
		parent::__construct();

		$this->setStyleName('pmk-TextBox');
	}
	
	function setMaxCharacters($size)
	{
		$this->size = $size;
	}

	function setMaxLength($maxLength)
	{
		$this->maxLength = $maxLength;
	}

	function setValue($value)
	{
		$this->value = $value;
	}
	
	function toString()
	{
		$str = '<input';

		if ($this->id != null)
			$str .= ' id="'.$this->id.'"';

		if ($this->name != null)
			$str .= ' name="'.$this->name.'"';

		if ($this->style != null)
			$str .= ' class="'.$this->style.'"';

		if ($this->size != null)
			$str .= ' size="'.$this->size.'"';

		if ($this->maxLength != null)
			$str .= ' maxlength="'.$this->maxLength.'"';

		if ($this->value != null)
			$str .= ' value="'.htmlspecialchars($this->value).'"';
			
		$str .= ' type="text">';
			
		return $str;
	}
}
?>